const state = {
  address: [
    {
      id: "1",
      name: "张三",
      tel: "13000000000",
      address: "浙江省杭州市西湖区文三路 138 号东方通信大厦 7 楼 501 室",
    },
    {
      id: "2",
      name: "李四",
      tel: "1310000000",
      address: "浙江省杭州市拱墅区莫干山路 50 号",
    },
  ],
};

const getters = {
  getAddress(state) {
    return state.address;
  },
};

const actions = {};
const mutations = {
  addAddress(state, addressinfo) {
    state.address.push(addressinfo);
  },
  editAddress(state, [index, addressinfo]) {
    state.address.splice(index, 1, addressinfo);
  },
  removeAddress(state, index) {
    state.address.splice(index, 1);
  },
  clearAddress(state) {
    for (let i = 0; i < state.address.length; i++) {
      state.address.splice(i, 1);
      i = i - 1;
    }
  },
};

export default {
  namespaced: true,
  state,
  getters,
  actions,
  mutations,
};
